package com.eh.template;

import com.eh.template.beverage.Coffee;
import com.eh.template.beverage.Tea;
import com.eh.template.duck.Duck;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Hashtable;

/**
 * Created by David on 2016/4/30.
 */
public class TemplateSimulator {
    public static void main(String[] args) {
        test2();
    }

    private static void test1() {
        new Tea().prepareRecipe();
        new Coffee().prepareRecipe();
    }

    private static void test2() {
        Duck[] ducks = new Duck[] { new Duck("Tom", 3), new Duck("Harry", 2),
                new Duck("Jack", 5), new Duck("Lisa", 1) };
        System.out.println("排序前：");
        display(ducks);
        Arrays.sort(ducks);
        System.out.println("排序后：");
        display(ducks);
    }

    private static void display(Duck[] ducks) {
        for (Duck duck : ducks) {
            System.out.println(duck);
        }
    }
}
